package tec.stan.ling.topo.model;

import java.util.LinkedList;
import java.util.List;

import org.xmappr.Element;
import org.xmappr.Elements;
import org.xmappr.RootElement;

import tec.stan.ling.core.notifier.NList;
import tec.stan.ling.core.top.model.Node;
import tec.stan.ling.core.top.model.Subnet;

@RootElement(name="Root")
public class SubnetImpl extends NodeImpl implements Subnet {

	@Elements({
		@Element(name="Subnet", targetType=SubnetImpl.class),
		@Element(name="Device", targetType=DeviceImpl.class),
	})
	private List<Node> children;

	public SubnetImpl(int id, Subnet parent) {
		this.id = id;
		this.setParent(parent);
		// this.type
	}

	public SubnetImpl(int id, Subnet parent, String name) {
		this(id, parent);
		this.setName(name);
	}

	@Override
	public List<Node> getChildren() {
		if (children == null) {
			children = new NList<Node>(new LinkedList<Node>(),
					Subnet.SUBNET_CHILDREN, this);
		}
		return children;
	}

}
